

using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using JYJ.AiYard.Authorization;

namespace JYJ.AiYard.StationManagement.TbYardIssuedCards.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="TbYardIssuedCardPermissions" /> for all permission names. TbYardIssuedCard
    ///</summary>
    public class TbYardIssuedCardAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public TbYardIssuedCardAuthorizationProvider()
		{

		}

        public TbYardIssuedCardAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public TbYardIssuedCardAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了TbYardIssuedCard 的权限。
			var pages = context.GetPermissionOrNull(AppLtmPermissions.Pages) ?? context.CreatePermission(AppLtmPermissions.Pages, L("Pages"));

			var administration = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_YardManage) ?? pages.CreateChildPermission(AppPermissions.Pages_YardManage, L("Yard_Management"));

			var entityPermission = administration.CreateChildPermission(TbYardIssuedCardPermissions.Node , L("TbYardIssuedCard"));
			entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.Query, L("QueryTbYardIssuedCard"));
			entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.Create, L("CreateTbYardIssuedCard"));
			entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.Edit, L("EditTbYardIssuedCard"));
            //entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.Delete, L("DeleteTbYardIssuedCard"));
            //entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchDelete, L("BatchDeleteTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.CardLogout, L("CardLogoutTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.CardDelay, L("CardDelayTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.ExportExcel, L("ExportExcelTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchDownLoad, L("DownLoadTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchAuthorization, L("BatchAuthorizationTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchLoadCardNo, L("BatchLoadCardNoTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchDelay, L("BatchDelayTbYardIssuedCard"));
            entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.BatchCardLogout, L("BatchCardLogoutTbYardIssuedCard"));
            //隐藏数据
            //entityPermission.CreateChildPermission(TbYardIssuedCardPermissions.ShowDeleteCardNo, L("ShowDeleteTbrOutYard"));
        }

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AppConsts.LocalizationSourceName);
		}
    }
}